#include <stdio.h>


struct ListNode* middleNode(struct ListNode* head){\
    struct ListNode* fast =head,*slow =head;
    while(fast && fast->next)
    {
        fast = fast->next->next;
        slow = slow ->next;
    }

    return slow;
}

struct ListNode* removeElements(struct ListNode* head, int val){
    struct ListNode* prev = NULL,*cur = head;
    while(cur)
    {
        if(cur->val == val)
        {
            //判断是不是头删
            if(cur == head)
            {
                head = cur->next;
                free(cur);
                cur = head;
            }else
            {
                prev->next = cur->next;
                free(cur);
                cur = prev->next;
            }
        }else
        {
            prev = cur;
            cur = cur->next;
        }
    }
    
    return head;
}


int main()
{
  
  
  return 0;
}
